using System;
using System.Collections.Generic;

namespace ZyGame
{
    public class QueryDataList : IDisposable
    {
        private Dictionary<string, object> map = new Dictionary<string, object>();

        public void SetData(string key, object value)
        {
            if (map.ContainsKey(key))
            {
                throw new Exception("the key is already exist");
            }

            map.Add(key, value);
        }

        public T GetData<T>(string key)
        {
            if (map.TryGetValue(key, out object m))
            {
                return (T)m;
            }

            return default;
        }

        public void Dispose()
        {
            map.Clear();
            GC.SuppressFinalize(this);
        }
    }
}